package vip.george.p1491;

public class P1491 {


    public double average(int[] salary) {
        int len = salary.length;
        int sum = 0;
        int min = salary[0];
        int max = salary[0];
        for (int i = 0; i < len; i++) {
            sum += salary[i];
            if (salary[i] < min) {
                min = salary[i];
            }
            if (salary[i] > max) {
                max = salary[i];
            }
        }
        return (sum - min - max) * 1.0 / (len - 2);
    }


    public static void main(String[] args) {
        P1491 p1491 = new P1491();
        System.out.println(p1491.average(new int[] {4000,3000,1000,2000}));
        System.out.println(p1491.average(new int[] {6000,5000,4000,3000,2000,1000}));
    }
}
